package ViewPackage;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;

import javax.swing.JComponent;

public class GameCanvas extends JComponent{
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private int xpos,ypos;
	
	
	//Az ervenyteleniteskor megjelenitett kep
	private Image image;
	
	//A kep merete
	public Dimension imageSize;
	
	
	public GameCanvas(int width,int height){
		
		imageSize=new Dimension(width,height);
		image = new BufferedImage(imageSize.width,imageSize.height,BufferedImage.TYPE_INT_RGB);
		
	}
	
	/*
	 * Ervenytelenedeskor ez a fuggveny hivodik meg.
	 * Mindig a GameCanvashoz tartozo image -t rajzolja ki
	 */
	public void paint(Graphics g){
		g.drawImage(image,0,0,null);
		
	}
	
	/*
	 * Visszater egy interfeszobjektummal,
	 * amivel az image attributumra lehet rajzolni
	 */
	public Graphics getImage(){
		return image.getGraphics();
	}
	public Dimension getMinimumSize(){
		return imageSize;
		
	}
	public Dimension getMaximumSize(){
		return imageSize;
		
	}
	public Dimension getPreferredSize(){
		return imageSize;
	}

	public void reDraw(){
		Graphics systemg=this.getGraphics();
		if(systemg!=null)this.update(systemg);
	}

	

}
